package org.mics.cyy.modular.notice.controller;

import javax.annotation.Resource;

import org.mics.core.response.OneDataResponse;
import org.mics.core.response.PageDataResponse;
import org.mics.core.response.SimpleResponse;
import org.mics.cyy.modular.notice.query.NoticeQuery;
import org.mics.cyy.modular.notice.request.NoticeRequest;
import org.mics.cyy.modular.notice.service.NoticeService;
import org.mics.cyy.modular.notice.vo.NoticeVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 通知公告
 * @author mics
 * @date 2023-10-10
 * @version  1.0
 */
@RestController
@RequestMapping("/notice")
@Tag(name = "通知公告")
public class NoticeController {
	@Resource
	private NoticeService noticeService;
	
	@Operation(summary =  "增加/修改公告")
    @RequestMapping(value = "/save",method = RequestMethod.POST)
	public SimpleResponse save(@Validated @RequestBody NoticeRequest noticeRequest ) {
		String id =   noticeService.save(noticeRequest);
		return new OneDataResponse<String>(id);
	}
	
	@Operation(summary =  "删除公告")
    @RequestMapping(value = "/delete/{id}",method = RequestMethod.DELETE)
	public SimpleResponse delete(@PathVariable("id") String id) {
		noticeService.delete(id);
        return new SimpleResponse();
	}
	
	@Operation(summary =  "公告列表")
    @RequestMapping(value = "/listByPage",method = RequestMethod.POST)
	public PageDataResponse<NoticeVO> listByPage(@RequestBody NoticeQuery pageQuery) {
		PageDataResponse<NoticeVO> pageDataResponse =   noticeService.listByPage(pageQuery);
		return pageDataResponse;
	}
	
}
